/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.shop.user.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.shop.user.api.dto.ShopCouponDTO;
import com.pig4cloud.pigx.shop.user.api.dto.ShopUserDTO;
import com.pig4cloud.pigx.shop.user.api.entity.ShopCoupon;
import com.pig4cloud.pigx.shop.user.api.entity.ShopUserCoupon;
import com.pig4cloud.pigx.shop.user.api.vo.ShopCouponVO;
import com.pig4cloud.pigx.shop.user.api.vo.ShopEquityVO;
import com.pig4cloud.pigx.shop.user.api.vo.ShopUserVO;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 商城优惠券
 *
 * @author pigx code generator
 * @date 2023-12-03 12:01:37
 */
public interface ShopCouponService extends IService<ShopCoupon> {

	/**
	 * 获取领取优惠券列表
	 * @param userId
	 * @return
	 */
	List<ShopCouponVO> getCouponList(Long userId);

	/**
	 * 获取用户可用的优惠券
	 * @return
	 */
	List<ShopCouponVO> getAvailableCoupon(Long shopUserId);

	/**
	 * 获取用户可用的优惠券
	 * @return
	 */
	List<ShopCouponVO> getMyCoupon(Long shopUserId);

	/**
	 * 分页获取用户可用的优惠券
	 * @param shopCouponDTO
	 * @return
	 */
	IPage<ShopCouponVO> getAvailableCouponPage(Page page, ShopCouponDTO shopCouponDTO);

	/**
	 * 用户领取优惠券
	 * @return
	 */
	R obtainCouponByUserId(Long userId, Long couponId);

	/**
	 * 判断优惠券是否可用
	 * @param shopUserCoupon
	 * @return
	 */
	R checkUserCouponStatue(ShopUserCoupon shopUserCoupon);

	/**
	 * 使用优惠券
	 * @param shopUserId
	 * @param shopUserCouponId
	 * @param orderId
	 * @return
	 */
	boolean useUserCoupon(Long shopUserId, Long shopUserCouponId, Long orderId);

	/**
	 * 发放优惠券给用户
	 * @param shopCouponVOS
	 * @return
	 */
	R giveCoupon(List<ShopCouponVO> shopCouponVOS);

	/**
	 * 根据用户领取的优惠券记录id获取优惠券信息
	 * @param shopUserCouponId
	 * @return
	 */
	ShopCoupon getCouponInfoByShopUserCouponId(Long shopUserCouponId);

	/**
	 * 判断权益包是否可以退款
	 * @param shopEquityVO
	 * @return
	 */
	R checkCancelEquityCoupons(ShopEquityVO shopEquityVO);

	/**
	 * 处理权益包退款，优惠券抵消
	 * @param shopEquityVO
	 * @return
	 */
	R cancelEquityCoupons(ShopEquityVO shopEquityVO);

	/**
	 * 退回优惠券
	 * @param shopUserCouponId
	 * @return
	 */
	R returnShopUserCoupon(Long shopUserCouponId);

}
